﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SdmxMl.UC
{
    public partial class UcDualList : UserControl
    {
        private bool _isFinal;
        public bool IsFinal 
        {
            get { return _isFinal; }
            set
            {
                _isFinal = value;
                listAssigned.Enabled = _isFinal == false;
                listAvailable.Enabled = _isFinal == false;
            }
        }

        public UcDualList()
        {
            InitializeComponent();
        }

        /// <summary> List container to holds available items </summary>
        public ListBox ListAvailable
        {
            get { return this.listAvailable; }
        }

        /// <summary> List container to holds selected items </summary>
        public ListBox ListAssigned
        {
            get { return this.listAssigned; }
        }

        /// <summary>
        /// Exposes the DualListAdd.
        /// </summary>
        public SdmxMl.UC.DualList DualListAdd
        {
            get { return dualListAdd; }
        }

        private void dualListAdd_AfterAction(object sender, DualListActionEventArgs e)
        {
            listAssigned.SelectedIndex = e.Index;
        }

        private void dualListDelete_AfterAction(object sender, DualListActionEventArgs e)
        {
            listAvailable.SelectedIndex = e.Index;
        }

        private void dualListAdd_BeforeAction(object sender, SdmxMl.UC.DualListActionCancelEventArgs e)
        {
        }

        private void DualListForm_Resize(object sender, System.EventArgs e)
        {
            int middle = this.panelMiddle.Width;
            int width = (this.Width / 2) - middle / 2;
            this.panelLeft.Width = width;
            this.panelRight.Width = width;
        }


    }
}
